<template>
	<view class="container">
		<view class="account">
			<view class="account-msg" @click="loginOut">
				<view class="header-msg_acount">退出账号</view>
				<view class="header-msg_tip">
					<image src="../../static/imgs/mine/right.png"></image>
				</view>
			</view>
			<view class="account-msg" @click="distory">
				<view class="header-msg_acount">注销账号</view>
				<view class="header-msg_tip">
					<image src="../../static/imgs/mine/right.png"></image>
				</view>
			</view>
			<view class="account-msg" @click="goUserAgree">
				<view class="header-msg_acount">用户协议</view>
				<view class="header-msg_tip">
					<image src="../../static/imgs/mine/right.png"></image>
				</view>
			</view>
			<view class="account-msg" @click="goAgree">
				<view class="header-msg_acount">隐私政策</view>
				<view class="header-msg_tip">
					<image src="../../static/imgs/mine/right.png"></image>
				</view>
			</view>
		</view>
		<uniPopup ref="distoryPopup">
			<uniPopupDialog
			type="type" 
			title="慎用注销功能" 
			content="注销账号后信息可能将会被删除，包括您购买的课程和权益。"
			cancelText="取消"
			confirmText="确定注销"
			@confirm="loginoutConfirm"></uniPopupDialog>
		</uniPopup>
		<uniPopup ref="loginoutPopup">
			<uniPopupDialog
			type="type" 
			title="是否退出账号" 
			content="退出账号后使用需要再次登录"
			cancelText="取消"
			confirmText="退出"
			@confirm="loginoutConfirm"></uniPopupDialog>
		</uniPopup>
	</view>
</template>

<script>
	import {getUser} from "../../static/js/api/user.js";
	import Cache from "../../static/js/cache.js";
	import uniPopup from "../../components/uni-popup/uni-popup.vue"
	import uniPopupDialog from "../../components/uni-popup/uni-popup-dialog.vue"
	export default {
		components:{
			uniPopup,
			uniPopupDialog
		},
		data() {
			return {
				userInfo:{},
			}
		},
		onLoad() {
			// this.getUserMsg()
		},
		methods: {
			getUserMsg(){
				getUser().then(res=>{
					console.log(res)
					this.userInfo = res.user
				})
			},
			goUserAgree(){
				uni.navigateTo({
					url:"/pages/login/user_agreement"
				})
			},
			goAgree(){
				uni.navigateTo({
					url:"/pages/login/agreement"
				})
			},
			distory(){
				this.$refs.distoryPopup.open()
			},
			loginOut(){
				this.$refs.loginoutPopup.open()
			},
			loginoutConfirm(){
				Cache.cache.clear();
				uni.reLaunch({
					url:"/pages/login/index"
				})
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	@import url("./index.scss");
	.account{
		width: 100%;
		height: 100rpx;
		
	}
	.account-msg{
		display: flex;
		align-items: center;
		justify-content: space-between;
		background-color: #fff;
		width: calc(100% - 60rpx);
		padding: 0 30rpx;
		margin-bottom: 10rpx;
		.header-msg_acount{
			font-weight: bold;
		}
		.header-msg_tip{
			font-weight: 400;
			image{
				width: 32rpx;
				height: 32rpx;
				vertical-align: sub;
			}
		}
	}
	.header-msg_acount,.header-msg_tip{
		color:$uni-text-color-black;
		line-height: 100rpx;
		font-size: 28rpx;
	}
</style>